package cn.tedu.csmall.passport.controller;


import cn.tedu.csmall.commons.web.JsonResult;
import cn.tedu.csmall.passport.pojo.vo.RoleListItemVo;
import cn.tedu.csmall.passport.service.RoleService;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/role")
@Api(tags = "04. 角色管理模块")/*@Api：添加在控制器类上，通过此注解的tags属性，可以配置模块名称*/
@Slf4j
@Validated
public class RoleController {

    @Autowired
    private RoleService roleService;

    // http://localhost:9181/role/list
    @GetMapping("/list")
    @PreAuthorize("hasAuthority('/ams/admin/read')")
    @ApiOperation("查询角色列表")
    @ApiOperationSupport(order = 420)
    public JsonResult list() {
        log.debug("开始处理【查询相册列表】的业务，无参数");
        List<RoleListItemVo> list = roleService.list();
        return JsonResult.ok(list);
    }

}
